home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / OpenDoc / OpenDoc Utilities / Interfaces / MemDebg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-01  |  2.7 KB  |  104 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        MemDebg.h
  3.  
  4.     Contains:    Memory management debugging routines
  5.  
  6.     Owned by:    Jens Alfke
  7.  
  8.     Copyright:    © 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>    02.10.1996    NP        1386083: Changed name of debugging routines
  13.          <2>    27.09.1996    NP        1386083: New routines MMFillHeap
  14.                                     and MMUnslockAllocations
  15.  
  16.     To Do:
  17. */
  18.  
  19.  
  20. #ifndef _MEMDEBG_
  21. #define _MEMDEBG_
  22. #pragma once
  23.  
  24. #ifndef _MEMMGR_
  25. #include "MemMgr.h"
  26. #endif
  27.  
  28.  
  29. #ifdef __cplusplus
  30.     class SOMObject;
  31.     class StackCrawl;
  32.     #define OPTIONAL    =0
  33. #else
  34.     #include <somobj.h>
  35.     typedef int StackCrawl;
  36.     #define OPTIONAL
  37. #endif
  38.  
  39.  
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43.  
  44. #pragma lib_export on
  45.  
  46.  
  47. void        MMBeginMemValidation( void );
  48. void        MMEndMemValidation( void );
  49. void        MMBeginHeapChecking( void );
  50. void        MMEndHeapChecking( void );
  51.  
  52. MMBoolean    MMValidatePtr( ConstMMBlock, MMBoolean validateHeap, const char *operation OPTIONAL );
  53. MMBoolean    MMValidateObject( const SOMObject *o );
  54. MMBoolean    MMValidateHandle( MMHandle );
  55.  
  56. MMBoolean    MMDoesHeapExist( MemHeap *heap );
  57. MMBoolean    MMValidateHeap( MemHeap *heapID, const void* ptr OPTIONAL );
  58. MMBoolean    MMValidateAllHeaps( void );
  59.  
  60. void        MMGetHeapInfo( MemHeap *heapID,
  61.                             const char* *name, size_t *allocated, size_t *free,
  62.                             size_t *nBlocks, size_t *nObjects );
  63.  
  64. typedef MMBoolean (*MMBlockInfoProc)( ConstMMBlock, size_t size, MMBoolean isObject, void *refCon );
  65.  
  66. void        MMWalkHeap( MemHeap *heapID, MMBlockInfoProc, void *refCon );
  67.  
  68. MMBoolean    MMFindBlockContaining( const void *start, const void *end,
  69.                     const void* *blockStart, const void* *blockEnd );
  70. MMBoolean    MMValidateMemoryRange( const void *start, const void *end );
  71.  
  72. MMBoolean    MMTrackStackCrawls( MMBoolean track );
  73. StackCrawl*    MMGetBlockStackCrawl( const void *block, long *flags );
  74. void        MMSetBlockStackCrawl( const void *block, StackCrawl*, long flags );
  75.  
  76. void        MMBeginLeakChecking( void );
  77. void        MMEndLeakChecking( void );
  78.  
  79.  
  80. typedef enum MMBlockType {
  81.     kMMBlock = 0x1,                // MM allocated block
  82.     kMMPlatformBlock = 0x2,        // Platform allocated block
  83.     kMMPlatformHandle = 0x4        // Platform allocated handle
  84. } MMBlockType;
  85.  
  86. /* These routines are used to simulate out-of-memory conditions. The current
  87.     amount of free space is noted at the time of the call. Any requests that
  88.     reduce the amount of free space beyond that threshold will fail. If some
  89.     memory is freed so that there is more free space than when the function
  90.     was called, then some allocations can occur as long as the threshold is
  91.     not exceeded.
  92.     You can activate/deactivate more than one type of allocation by adding
  93.     MMBlockType types together. */
  94. void MMFillHeap(MMBlockType whichAllocations);
  95. void MMUnfillHeap(MMBlockType whichAllocations);
  96.  
  97. #pragma lib_export off
  98.  
  99. #ifdef __cplusplus
  100. }
  101. #endif
  102.  
  103. #endif /*_MEMDEBG_*/
  104.